home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 May / macformat-037.iso / Shareware City / Science / CFG 2.3 (Shareware) / CFG & Frontier / (cfgMovieDemo) / cfgMovieDemo.c next >
Encoding:
C/C++ Source or Header  |  1994-03-15  |  1.2 KB  |  84 lines  |  [TEXT/MPCC]

  1.  
  2. /*© copyright 1991-93 UserLand Software, Inc. All RIghts Reserved.*/
  3.  
  4.  
  5. #include <math.h>
  6. #include <ucmd.h>
  7.  
  8.  
  9. #define logtoken        'log '
  10. #define exptoken        'exp '
  11. #define stepMultiple    'stpM'
  12.  
  13.  
  14. int errno; /*see math.c*/
  15.  
  16.  
  17. static void logverb (void);
  18. static void expverb (void);
  19. static void stepMultipleVerb (void);
  20.  
  21.  
  22. static void logverb (void)
  23. {
  24.     double x;
  25.     
  26.     if (!IACgetdoubleparam ((OSType) keyDirectObject, &x))
  27.         return;
  28.         
  29.     x = log (x);
  30.     IACreturndouble (x);
  31. }
  32.     
  33.  
  34. static void expverb (void)
  35. {
  36.     double x;
  37.     
  38.     if (!IACgetdoubleparam ((OSType) keyDirectObject, &x))
  39.         return;
  40.         
  41.     x = exp (x);
  42.     IACreturndouble (x);
  43. }
  44.     
  45.  
  46. static void stepMultipleVerb (void)
  47. {
  48.     double steps, scale, multiple;
  49.     
  50.     if (!IACgetdoubleparam('scal', &scale))
  51.         return;
  52.     if (!IACgetdoubleparam('step', &steps))
  53.         return;
  54.     
  55.     if ((scale < 1.0) || (steps < 2.0))
  56.         IACreturndouble( 0.0 );
  57.     else
  58.     {
  59.         multiple = exp( log( scale ) / (steps - 1.0) );
  60.         IACreturndouble( multiple );
  61.     }
  62. }
  63.     
  64.  
  65. void UCMDmain (void)
  66. {
  67.     switch (IACgetverbtoken ())
  68.     {
  69.         case logtoken:
  70.             logverb (); break;
  71.             
  72.         case exptoken:
  73.             expverb (); break;
  74.         
  75.         case stepMultiple:
  76.             stepMultipleVerb(); break;
  77.  
  78.         default:
  79.             IACnothandlederror (); break;
  80.     }
  81. }
  82.  
  83.  
  84.